package lex.mtd.utils.prefs;

import java.io.File;

import lex.mtd.Download;

public class Prefs {
	public static File getDownloadDirectory() {
		return new File(get(Keys.DOWNLOAD_DIRECTORY));
	}

	// bytes
	public static int getMinimalDataBlock() {
		return Integer.parseInt(get(Keys.MINIMAL_DATA_BLOCK));
	}

	// seconds
	public static int getMinimalTimeBlock() {
		return Integer.parseInt(get(Keys.MINIMAL_TIME_BLOCK));
	}

	public static int getThreadLimite() {
		return Integer.parseInt(get(Keys.THREAD_LIMIT));
	}

	// milliseconds
	public static int getUIRefreshDelay() {
		return Integer.parseInt(get(Keys.UI_REFRESH_DELAY));
	}

	private static String get(String key) {
		String value = Download.getApplication().getContext().getResourceMap().getString(key);
		if (null == value || value.isEmpty())
			value = Keys.getDefaultConfiguration().getString(key);
		return value;
	}

	private Prefs() {
	};
}
